import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '配置键',
    align: 'center',
    dataIndex: 'configKey',
  },
  {
    title: '配置值',
    align: 'center',
    dataIndex: 'configValue',
  },
  {
    title: '配置类型',
    align: 'center',
    dataIndex: 'configType',
  },
  {
    title: '配置描述',
    align: 'center',
    dataIndex: 'description',
  },
  {
    title: '页面类型',
    align: 'center',
    dataIndex: 'pageType',
  },
  {
    title: '排序权重',
    align: 'center',
    dataIndex: 'sortOrder',
  },
  {
    title: '状态',
    align: 'center',
    dataIndex: 'status_dictText',
  },
  {
    title: '创建时间',
    align: 'center',
    dataIndex: 'createTime',
  },
  {
    title: '更新时间',
    align: 'center',
    dataIndex: 'updateTime',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '配置键',
    field: 'configKey',
    component: 'JInput',
    colProps: { span: 4 },
    componentProps: {
      placeholder: '请输入配置键',
    },
  },
  {
    label: '配置值',
    field: 'configValue',
    component: 'JInput',
    colProps: { span: 4 },
    componentProps: {
      placeholder: '请输入配置键',
    },
  },
  {
    label: '配置类型',
    field: 'configType',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      placeholder: '请选择配置类型',
      allowClear: true,
      options: [
        { label: '字符串', value: 'string' },
        { label: '数字', value: 'number' },
        { label: '布尔值', value: 'boolean' },
        { label: 'JSON', value: 'json' },
        { label: '数组', value: 'array' },
      ],
    },
  },
  {
    label: '页面类型',
    field: 'pageType',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      placeholder: '请选择页面类型',
      allowClear: true,
      options: [
        { label: '首页', value: 'home' },
        { label: '博客', value: 'blog' },
        { label: '关于', value: 'about' },
        { label: '联系', value: 'contact' },
        { label: '管理后台', value: 'admin' },
        { label: '全局', value: 'global' },
      ],
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      placeholder: '请选择状态',
      allowClear: true,
      options: [
        { label: '禁用', value: 0 },
        { label: '启用', value: 1 },
      ],
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '配置键',
    field: 'configKey',
    component: 'Input',
    dynamicRules: () => {
      return [{ required: true, message: '请输入配置键!' }];
    },
  },
  {
    label: '配置值',
    field: 'configValue',
    component: 'InputTextArea',
  },
  {
    label: '配置类型',
    field: 'configType',
    component: 'Input',
  },
  {
    label: '配置描述',
    field: 'description',
    component: 'Input',
  },
  {
    label: '页面类型',
    field: 'pageType',
    component: 'Input',
  },
  {
    label: '排序权重',
    field: 'sortOrder',
    component: 'InputNumber',
  },
  {
    label: '状态(0:禁用,1:启用)',
    field: 'status',
    component: 'InputNumber',
  },
  {
    label: '创建时间',
    field: 'createdTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    label: '更新时间',
    field: 'updatedTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  configKey: { title: '配置键', order: 0, view: 'text', type: 'string' },
  configValue: { title: '配置值', order: 1, view: 'textarea', type: 'string' },
  configType: { title: '配置类型', order: 2, view: 'text', type: 'string' },
  description: { title: '配置描述', order: 3, view: 'text', type: 'string' },
  pageType: { title: '页面类型', order: 4, view: 'text', type: 'string' },
  sortOrder: { title: '排序权重', order: 5, view: 'number', type: 'number' },
  status: { title: '状态(0:禁用,1:启用)', order: 6, view: 'number', type: 'number' },
  createdTime: { title: '创建时间', order: 7, view: 'datetime', type: 'string' },
  updatedTime: { title: '更新时间', order: 8, view: 'datetime', type: 'string' },
};

/**
 * 流程表单调用这个方法获取formSchema
 * @param param
 */
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
